<block name="body"> 	
    <form action="{:U()}" method="post" id="info_form" name="info_form"  class="form-horizontal form-wrap"> 
	     <table class="table_form" style="width:600px">                     
			<tr>
				<th>广告名称：</th>
				<td>
					<input type="text" class="text input-7x" name="ad_name" value="{$info.ad_name|default="自定义广告名称"}" >  
				</td>
			</tr>           
			<tr>
				<th>广告类型：</th>
				<td>
					<select name="media_type" class="input-sm">
						 <option value="0">图片</option>                                             
						 <option value="1">flash</option>
					</select>                                
				</td>
			</tr>  
			<tr>
				<th>广告位置：</th>
				<td>
					<select name="pid" class="input-sm">
						<volist name="plist" id="item">
							   <option value="{$item.position_id}" <if condition="$info[pid] eq $item[position_id]">selected</if>>{$item.position_name}</option>
					   </volist>                  
					</select>      
				</td>
			</tr>  
			<tr>
				<th>开始日期：</th>
				<td>
				  <input type="text" name="start_time" onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss'})"  id="start_time" class="text input-7x" value="{:xdate('Y-m-d H:i:s',$info[start_time])}">
				</td>
			</tr>  
			<tr>
				<th>结束时间：</th>
				<td>
				  <input type="text" name="end_time"  onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss'})" id="end_time" class="text input-7x" value="{:xdate('Y-m-d H:i:s',$info[end_time])}">
				</td>
			</tr>  


			<tr>
				<th>广告链接：</th>
				<td>
					<input type="text"class="text input-mid" name="ad_link" value="{$info.ad_link}" >
				</td>
			</tr> 

			<tr>
				<th>广告图片：</th>
				<td>
			    		<input type="file" id="upload_picture">
						<input type="hidden" name="ad_code" id="ad_code" value="{$info['ad_code']|default=''}"/>
						<div class="upload-img-box">
						 <notempty name="info['ad_code']">
						  <div class="upload-pre-item"><img src="{$info.ad_code|get_cover='path'}"/></div>
						 </notempty>
						 </div>
				</td>
			</tr>

			<tr>
				<th>默认排序：</th>
				<td>
					<input type="text" class="text input-small" name="orderby" value="{$info.orderby}"  placeholder="50">
				</td>
			</tr>                                                      
    </table>
   <input type="hidden" name="id" value="{$id}">

    </form>
</block>

<block name="script">
<script type="text/javascript">
			//上传图片
            think.use('datepicker','uploadify',function(){		
				    /* 初始化上传插件 */
					$("#upload_picture").uploadify({
				        "height"          : 30,
				        "swf"             : "__STATIC__/uploadify/uploadify.swf",
				        "fileObjName"     : "download",
				        "buttonText"      : "上传图片",
				        "uploader"        : "{:U('File/uploadPicture',array('session_id'=>session_id(),'type'=>'ad'))}",
				        "width"           : 120,
				        'removeTimeout'	  : 1,
				        'fileTypeExts'	  : '*.jpg; *.png; *.gif;',
				        "onUploadSuccess" : uploadPicture,
				        'onFallback' : function() {
				            alert('未检测到兼容版本的Flash.');
				        }
				    });
					function uploadPicture(file, data){
				    	var data = $.parseJSON(data);
				    	var src = '';
				        if(data.status){
				        	$("#ad_code").val(data.id);
				        	src = data.url || '__ROOT__' + data.path;
				        	$("#ad_code").parent().find('.upload-img-box').html(
				        		'<div class="upload-pre-item"><img src="' + src + '"/></div>'
				        	);
				        } else {
				        	think.tip_error(data.info);
				        	setTimeout(function(){
				                $('#top-alert').find('button').click();
				                $(that).removeClass('disabled').prop('disabled',false);
				            },1500);
				        }
				    }
			  });
</script>

<script type="text/javascript" charset="utf-8">                 
 
    $(function() {       
      $('#info_form').ajaxForm({beforeSubmit: showloading, success: complate, dataType: 'json'});         
       function showloading() { 
		   name=$('#ad_name').val();
		   if(name==''){
			   think.tip_error('广告名称!');
			   return false;
			  }
        }  
        function complate(result) {
            if (result.status == 1) {
                  think.tip_success('保存成功');
                  window.location.reload();
            } else {
                think.tip_error(result.msg);
            }
        }
    });

</script>  
</block>